﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BudgetSV.Common
{
    public class Files
    {
        public static string GetFileIconByName(string fileName)
        {
            var ar = fileName.Split('.');
            var ers = ar[ar.Length - 1];
            //if (ers == "accdb" || ers == "ACCDB") { return "accbc.png"; }
            //if (ers == "chm" || ers == "CHM") { return "chm.png"; }
            if (ers == "doc" || ers == "DOC") { return "word.gif"; }
            if (ers == "docx" || ers == "DOCX") { return "word.gif"; }
            //if (ers == "exe" || ers == "EXE") { return "exe.png"; }
            //if (ers == "mdb" || ers == "MDB") { return "mdb.png"; }
            if (ers == "pdf" || ers == "PDF") { return "pdf.gif"; }
            if (ers == "ppt" || ers == "PPT") { return "ppt.gif"; }
            if (ers == "pptx" || ers == "PPTX") { return "ppt.gif"; }
            if (ers == "txt" || ers == "TXT") { return "txt.gif"; }
            if (ers == "xls" || ers == "XLS") { return "excel.gif"; }
            if (ers == "xlsx" || ers == "XLSX") { return "excel.gif"; }
            if (ers == "htm" || ers == "html" || ers == "HTM" || ers == "HTML") { return "htm.png"; }
            //if (ers == "bmp" || ers == "jpg" || ers == "jpeg" || ers == "png" || ers == "gif"
            //    || ers == "BMP" || ers == "JPG" || ers == "JPEG" || ers == "PNG" || ers == "GIF"
            //    ) { return "img.png"; }
            //if (ers == "rar" || ers == "zip" || ers == "z" || ers == "gz" || ers == "tgz" || ers == "bz2" || ers == "tar"
            //    || ers == "RAR" || ers == "ZIP" || ers == "Z" || ers == "GZ" || ers == "TGZ" || ers == "BZ2" || ers == "TAR"
            //    ) { return "rar.png"; }
            return "txt.gif";
        }
        public static string GetFiconByFname(string fname)
        {
            var ar = fname.Split('.');
            var ers = ar[ar.Length - 1];
            if (ers == "accdb" || ers == "ACCDB") { return "accbc.png"; }
            if (ers == "chm" || ers == "CHM") { return "chm.png"; }
            if (ers == "doc" || ers == "DOC") { return "doc.png"; }
            if (ers == "docx" || ers == "DOCX") { return "docx.png"; }
            if (ers == "exe" || ers == "EXE") { return "exe.png"; }
            if (ers == "mdb" || ers == "MDB") { return "mdb.png"; }
            if (ers == "pdf" || ers == "PDF") { return "pdf.png"; }
            if (ers == "ppt" || ers == "PPT") { return "ppt.png"; }
            if (ers == "pptx" || ers == "PPTX") { return "pptx.png"; }
            if (ers == "txt" || ers == "TXT") { return "txt.png"; }
            if (ers == "xls" || ers == "XLS") { return "xls.png"; }
            if (ers == "xlsx" || ers == "XLSX") { return "xlsx.png"; }
            if (ers == "htm" || ers == "html" || ers == "HTM" || ers == "HTML") { return "htm.png"; }
            if (ers == "bmp" || ers == "jpg" || ers == "jpeg" || ers == "png" || ers == "gif"
                || ers == "BMP" || ers == "JPG" || ers == "JPEG" || ers == "PNG" || ers == "GIF"
                ) { return "img.png"; }
            if (ers == "rar" || ers == "zip" || ers == "z" || ers == "gz" || ers == "tgz" || ers == "bz2" || ers == "tar"
                || ers == "RAR" || ers == "ZIP" || ers == "Z" || ers == "GZ" || ers == "TGZ" || ers == "BZ2" || ers == "TAR"
                ) { return "rar.png"; }
            return "unknow.png";
        }
        public static string GetnewFpath(string path)
        {
            var fname = path.Substring(path.LastIndexOf("\\") + 1, path.Length - 1 - path.LastIndexOf("\\"));
            var fpth = path.Substring(0, path.Length - fname.Length);
            var ar = fname.Split('.');
            var ers = fname.Substring(ar[0].Length, fname.Length - ar[0].Length);

            return fpth + ar[0] + "(" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ")" + ers;
        }
    }
}